<template>
	<view>	
		<u-navbar title="考试结果"></u-navbar>
		<view class="wrap u-m-t-30" style="background-color: #FFFFFF;">
			<view class="u-progress" style="text-align: center;">
				<u-circle-progress type="error" :percent="89" :width="375" :border-width="40" duration="2000">
					<view class='u-progress-info'>89分</view><br>
					<view class='u-progress-info'>通过</view>
				</u-circle-progress>
			</view>
			<view class=" u-m-t-30">
				<u-row gutter="16">
					<u-col span="6">
						<view class="u-text-center">30分钟</view>
						<view class="u-text-center">答题时长</view>
					</u-col>
					<u-col span="6">
						<view class="u-text-center">30分钟</view>
						<view class="u-text-center">答题时长</view>
					</u-col>
				</u-row>
			</view>
			<view class="u-m-t-30">
				<view class="">
					<text class="u-font-32 u-m-l-20">
						错误题目（{{errorList.length}}）
					</text>
					<image style="width: 24rpx;height: 24rpx;" src="../../static/arrow-down@2x.png" mode="widthFix"></image>
				</view>
				<view class="u-m-t-30">
					<u-row gutter="16">
						<u-col span="2" v-for="(item,index) in errorList">
							<u-tag :text="item.id" type="error" shape="circle" />
						</u-col>
					</u-row>
				</view>
			</view>
			<view class="u-m-t-30">
				<view class="">
					<text class="u-font-32 u-m-l-20">
						正确题目（{{rightList.length}}）
					</text>
					<image style="width: 24rpx;height: 24rpx;" src="../../static/arrow-down@2x.png" mode="widthFix"></image>
				</view>
				<view class="u-m-t-30">
					<u-row gutter="16">
						<u-col span="2" v-for="(item,index) in rightList">
							<u-tag :text="item.id" type="success" shape="circle" />
						</u-col>
					</u-row>
				</view>
			</view>
			<view class="u-button-wrap u-m-t-30" style="text-align: center;">
				<u-button  @click="analysis()" shape="circle" class="u-m-r-15" size="medium">考试解析</u-button>
				<u-button  @click="certificate()" shape="circle" class="u-m-l-15" size="medium">查看证书</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				questionList: [{
						id: 1,
						title: "在以下数据类型中，不是Java基础数据类型的是( )",
						type: 1,
						optionList: [{
							id: "A",
							content: "int"
						}, {
							id: "B",
							content: "double"
						}, {
							id: "C",
							content: "char"
						}, {
							id: "D",
							content: "String"
						}],
						answer: "D",
						userAnswer: "",
						explain: "String类型是引用数据类型，不属于基本数据类型"
					},
					{
						id: 2,
						title: "Java所定义的版本中不包括( )",
						type: 1,
						optionList: [{
							id: "A",
							content: "J2EE"
						}, {
							id: "B",
							content: "J2ME"
						}, {
							id: "C",
							content: "J2SE"
						}, {
							id: "D",
							content: "J2HE"
						}],
						answer: "D",
						userAnswer: "",
						explain: "本题考察的是Java的发展简史，Java版本包括J2EE 、 J2ME 、 J2SE ，不存在J2HE"
					},
					{
						id: 3,
						title: "下列选项中不属于Java算术运算符的是( )。",
						type: 1,
						optionList: [{
							id: "A",
							content: "/"
						}, {
							id: "B",
							content: "%"
						}, {
							id: "C",
							content: "*"
						}, {
							id: "D",
							content: "!="
						}],
						answer: "D",
						userAnswer: "",
						explain: "!= 是逻辑运算符"
					},
					{
						id: 4,
						title: "在Java中,( )方法可以比较两个对象的值是否相等,如两个对象值相等,则返回true。",
						type: 1,
						optionList: [{
							id: "A",
							content: "toString()"
						}, {
							id: "B",
							content: "equals()"
						}, {
							id: "C",
							content: "compare()"
						}, {
							id: "D",
							content: "以上所有选项都不正确"
						}],
						answer: "B",
						userAnswer: "",
						explain: "java.lang包中Object的equals方法将比较两个对象是否相等，如果相等则返回true"
					},
					{
						id: 5,
						title: "在Java中,java.util.Arrays类中用来排序的方法是( )。",
						type: 1,
						optionList: [{
							id: "A",
							content: "sort()"
						}, {
							id: "B",
							content: "sorp()"
						}, {
							id: "C",
							content: "paixu()"
						}, {
							id: "D",
							content: "list()"
						}],
						answer: "A",
						userAnswer: "",
						explain: "Arrays是Java提供的一个类，而sort()是该类的一个方法，用于完成对数组的排序（升序）。因此A是正确选项"
					},
				],
				rightList:[],
				errorList:[]
			}
		},
		onLoad() {
			const userAnswerArr = uni.getStorageSync('userAnswerArr');
			if (userAnswerArr) {
				for (var i = 0;i< this.questionList.length ;i++) {
					for (var j = 0 ;j < userAnswerArr.length ;j++) {
						if (this.questionList[i].id == userAnswerArr[j].id) {
							this.questionList[i].userAnswer = userAnswerArr[j].value;
						}
					}
				}
				for(let i = 0;i<this.questionList.length;i++){
					if(this.questionList[i].userAnswer == this.questionList[i].answer){
						this.rightList.push(this.questionList[i])
					}else{
						this.errorList.push(this.questionList[i])
					}
				}
			}
		},
		methods:{
			analysis(){
				uni.navigateTo({
					url:'./analysis'
				})
			},
			certificate(){
				
			}
		}
	}
</script>

<style>
</style>
